﻿Imports System.Data.SqlClient

Module GlobalSettings

    Function LoadDataView(ByVal SqlString As String, ByVal ConnectionString As String, ByRef succeed As Boolean) As DataView

        Dim connection As SqlConnection
        Dim command As SqlCommand
        Dim adapter As New SqlDataAdapter
        Dim ds As New DataSet

        connection = New SqlConnection(ConnectionString)

        Try
            connection.Open()

            command = New SqlCommand(SqlString, connection)

            adapter.SelectCommand = command
            adapter.Fill(ds, "Create DataView")
            adapter.Dispose()
            command.Dispose()
            connection.Close()
            succeed = True
            Return ds.Tables(0).DefaultView
        Catch ex As Exception
            succeed = False
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return Nothing
        End Try

    End Function

End Module
